var vm_jingfeipiciqueren = new Vue({
    el: "#jingfeipiciqueren",
    data: {
        deptid: $("#deptid").val(),		// 单位ID

        jingfeipicilist: [],// 单位经费批次list

        //查询用字段
        picimingcheng: '',

        //
        editflag: '',

    },
    created: function () {
        var _this = this;
        _this.bindJingfeiPiciList();

    },
    methods: {

        // 根据单位ID查询 单位经费批次
        bindJingfeiPiciList: function () {
            var _this = this;
            $.post('/system/jingfeipici/findDeptPici', {
                deptId: _this.deptid,
                picimingcheng: _this.picimingcheng
            }, function (ppData) {
                if (ppData != null) {
                    if (ppData.result == 1) {
                        var data = ppData.resultContent;
                        _this.jingfeipicilist = data;
                        _this.jingfeipicilist = _this.jingfeipicilist.filter(item => item.isfafang == true);
                    } else {
                        layer.alert(ppData.message);
                    }
                }
            }, "json");
        },

        //确认收款
        QuerenShoukuan: function (jingfeipiciitem) {
            var _this = this;
            var jingfeipici_layer = layer.open({type: 3});
            $.post('/system/jingfeidept/querenshoukuan', {
                deptid: _this.deptid,
                jingfeipiciId: jingfeipiciitem.jingfeipiciid
            }, function (ppData) {
                layer.close(jingfeipici_layer);
                if (ppData != null) {
                    if (ppData.result == 1) {
                        layer.open({
                            time: 1000,
                            btn: [],
                            content: "收款成功!",
                        })
                        _this.bindJingfeiPiciList()
                    } else {
                        layer.alert(ppData.message);
                    }
                }
            }, "json");
        },

        //发放经费
        FafangJingfei: function (jingfeipiciitem) {
            var _this = this;
            var jingfeipici_layer = layer.open({type: 3});
            $.post('/system/jingfeidept/fafang', {
                deptid: _this.deptid,
                jingfeipiciId: jingfeipiciitem.jingfeipiciid
            }, function (ppData) {
                layer.close(jingfeipici_layer);
                if (ppData != null) {
                    if (ppData.result == "1") {

                        layer.open({
                            time: 1000,
                            btn: [],
                            content: "发放成功!",
                        })
                        _this.bindJingfeiPiciList()
                    } else {
                        layer.alert(ppData.message);
                    }
                }
            }, "json");
        },
        //计算津贴
        toJisuan: function (jingfeipiciitem) {
            var _this = this;
            var jingfeipici_layer = layer.open({type: 3});
            $.post('/system/jingfeipici/jisuan', {
                id: jingfeipiciitem.jingfeipiciid,
                deptid: _this.deptid,
                jisuanshijian:jingfeipiciitem.jisuanshijian,
                rdm: Math.random()
            }, function (ppData) {
                layer.close(jingfeipici_layer);
                if (ppData != null) {
                    if (ppData.result == "1") {
                        layer.open({
                            time: 1000,
                            btn: [],
                            content: "计算成功!",
                        });
                        _this.bindJingfeiPiciList();
                    } else {
                        layer.alert(ppData.message);
                    }
                }
            }, "json");
        },
/*        //查看
        toJingfeiPiciDetail: function (jingfeipiciitem) {
            $.modal.openTab("单位拨款详情", 'system/jingfeipici/jingfei_queren?jingfeipiciid=' + jingfeipiciitem.jingfeipiciid + "&deptid=" + this.deptid, false);
        },*/
        //重置
        Reset: function () {
            this.picimingcheng=null;
            this.bindJingfeiPiciList();
        }

    },
})